package java01_type;

import org.junit.jupiter.api.Test;

/**
 * 在项目中，很少用char，一般用String
 */
public class Test02_Char {

    @Test
    void testChar() {
        char a = 'A';
        char b = 'B';
        System.out.println(a + b);

        char c = '中';
        System.out.println(Integer.valueOf(c));

        char d = 100;
        System.out.println(d);
    }

    /**
     * ASCII码 <= 127都是有缓存的，所以==返回true，最好用equals判断
     */
    @Test
    void testCharacter() {
        Character a = 'a';
        Character b = Character.valueOf('a');
        System.out.println(a == b);//true
        System.out.println(a.equals(b));//true

        Character aa = '中'; //20013
        Character bb = Character.valueOf('中');
        System.out.println(aa == bb);//false
        System.out.println(aa.equals(bb));//true
    }
}
